layui.use(['layer', 'table', 'ax', 'laydate'], function () {
    var $ = layui.$;
    var $ax = layui.ax;
    var layer = layui.layer;
    var table = layui.table;
    var laydate = layui.laydate;
    layui.use(['ax'], function () {
        var $ax = layui.ax;
        let val = $("#type").val();
        var ajax = new $ax(Feng.ctxPath + "/log/getChartsData?logType="+val, function (data) {
            var myChart = echarts.init(document.getElementById('echar1'));
            myChart.setOption({
                title: {
                    text: '日志日统计',
                    left: 'center'
                },
                xAxis: {
                    type: 'category',
                    data: data.date
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    data: data.numList,
                    type: 'bar'
                }]
            });

        }, function (data) {
            Feng.success("系统错误:"+data.responseText);
        });
        ajax.start();
    });
    layui.use(['ax'], function () {
        var $ax = layui.ax;
        let val = $("#type").val();
        var ajax = new $ax(Feng.ctxPath + "/log/getChartsData2?logType="+val, function (data) {
            var myChart2 = echarts.init(document.getElementById('echar2'));
            console.log(data);
            // var echarData = data;
            var echarData1 = [{name:"aa",value:22}]
            var echarData  =    [
                {value: 1048, name: '搜索引擎'},
                    {value: 735, name: '直接访问'},
                    {value: 580, name: '邮件营销'},
                    {value: 484, name: '联盟广告'},
                    {value: 300, name: '视频广告'}
                ]
            myChart2.setOption({
                title: {
                    text: '日志分类统计',
                    left: 'center'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                },
                series: [
                    {
                        name: '类别',
                        type: 'pie',
                        radius: '50%',
                        data: data,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            });


        }, function (data) {
            Feng.success("系统错误:"+data.responseText);
        });
        ajax.start();
    });
});
